package com.iwuke.dance.util;

import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.text.style.RelativeSizeSpan;
import android.text.style.StyleSpan;
import android.widget.TextView;

import com.iwuke.dance.R;
import com.iwuke.dance.activity.LPWHApplication;

public class TextUtil {

    public static void setTextAppointment(TextView textView, String content_1, String content_2){
        textView.setText("");//"¥"
        SpannableString sStr = new SpannableString(content_1 + content_2);
        sStr.setSpan(new ForegroundColorSpan(LPWHApplication.getContext().getResources().getColor(R.color.color_666,null))
                ,0,content_1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);//设置字体颜色
        if (!TextUtils.isEmpty(content_2)){
            sStr.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),  content_1.length(), content_1.length()+content_2.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); //粗体
        }
        textView.append(sStr);
    }

    public static void setTextCoupon(TextView textView, String content_1, String content_2){
        textView.setText("");//"¥"
        SpannableString sStr = new SpannableString(content_1 + content_2);
        //设置字体大小（相对值,单位：像素） 参数表示为默认字体大小的多少倍   ,0.5表示一半
        sStr.setSpan(new RelativeSizeSpan(0.6f), 0, content_1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        textView.append(sStr);

    }

    public static void setTextIncomeAnalysis(TextView textView, String content_1, String content_2){
        textView.setText("");
        SpannableString sStr = new SpannableString(content_1 + content_2);
        sStr.setSpan(new ForegroundColorSpan(LPWHApplication.getContext().getResources().getColor(R.color.color_666,null))
                ,content_1.length(),content_1.length()+content_2.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);//设置字体颜色
        //sStr.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, content_1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); //粗体
        sStr.setSpan(new RelativeSizeSpan(0.8f), content_1.length(),content_1.length()+content_2.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        textView.append(sStr);
    }

    public static void setTextUtil(TextView textView, String content_1, String content_2){
        textView.setText("");
        SpannableString sStr = new SpannableString(content_1 + content_2);
        sStr.setSpan(new ForegroundColorSpan(LPWHApplication.getContext().getResources().getColor(R.color.color_666,null))
                , 0, content_1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);//设置字体颜色
        if (!TextUtils.isEmpty(content_2)){
            sStr.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),  content_1.length(), content_1.length()+content_2.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); //粗体
        }
        textView.append(sStr);
    }

    public static void setTextTime(TextView textView, String content_1, String content_2, String content_3){
        textView.setText("");
        SpannableString sStr = new SpannableString(content_1 + content_2 + content_3);
        sStr.setSpan(new ForegroundColorSpan(LPWHApplication.getContext().getResources().getColor(R.color.color_5ed,null))
                , content_1.length(), content_1.length()+content_2.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);//设置字体颜色
        textView.append(sStr);
    }

    public static void setTextProportion(TextView textView, String content_1, String content_2,int color){
        textView.setText("");
        SpannableString sStr = new SpannableString(content_1 + content_2);
        sStr.setSpan(new ForegroundColorSpan(LPWHApplication.getContext().getResources().getColor(color,null))
                ,0,content_1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);//设置字体颜色
        sStr.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, content_1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); //粗体
        sStr.setSpan(new RelativeSizeSpan(0.7f), content_1.length(),content_1.length()+content_2.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        textView.append(sStr);
    }

    public static void setTextOnly(TextView textView, String content_1, String content_2,String content_3,int color){
        textView.setText("");
        SpannableString sStr = new SpannableString(content_1 + content_2 + content_3);
        sStr.setSpan(new ForegroundColorSpan(LPWHApplication.getContext().getResources().getColor(color,null))
                ,0,content_1.length()+content_2.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);//设置字体颜色
        sStr.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, content_1.length()+content_2.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); //粗体
        sStr.setSpan(new RelativeSizeSpan(0.5f), 0,content_1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        sStr.setSpan(new RelativeSizeSpan(0.7f), content_1.length()+content_2.length(),content_1.length()+content_2.length()+content_3.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        textView.append(sStr);
    }

    public static void setTextMemberName(TextView textView, String content_1, String content_2,int color){
        textView.setText("");
        SpannableString sStr = new SpannableString(content_1 + content_2);
        sStr.setSpan(new ForegroundColorSpan(LPWHApplication.getContext().getResources().getColor(color,null))
                ,0,content_1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);//设置字体颜色
        sStr.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, content_1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); //粗体
        sStr.setSpan(new RelativeSizeSpan(0.75f), content_1.length(),content_1.length()+content_2.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        textView.append(sStr);
    }

    /*累计充值*/
    public static void setTextCumulativeRecharge(TextView textView, String content_1, String content_2,String content_3){
        textView.setText("");
        SpannableString sStr = new SpannableString(content_1 + content_2+content_3);

        sStr.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, content_1.length()+content_2.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); //粗体
        sStr.setSpan(new RelativeSizeSpan(0.7f), content_1.length(),content_1.length()+content_2.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        sStr.setSpan(new RelativeSizeSpan(0.5f), content_1.length()+content_2.length(),content_1.length()+content_2.length()+content_3.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        textView.append(sStr);
    }

    public static void setTextAccountBalance(TextView textView, String content_1, String content_2,int color){
        textView.setText("");
        SpannableString sStr = new SpannableString(content_1 + content_2);
        sStr.setSpan(new ForegroundColorSpan(LPWHApplication.getContext().getResources().getColor(color,null))
                ,0,content_1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);//设置字体颜色
        sStr.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), content_1.length(), content_1.length()+content_2.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); //粗体
        sStr.setSpan(new RelativeSizeSpan(0.77f), 0,content_1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        textView.append(sStr);
    }

    public static void setAmountOfMoney(TextView textView, String content_1, String content_2){
        textView.setText("");
        SpannableString sStr = new SpannableString(content_1 + content_2);
        sStr.setSpan(new ForegroundColorSpan(LPWHApplication.getContext().getResources().getColor(R.color.color_333,null))
                ,0,content_1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);//设置字体颜色
        //sStr.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), 0, content_1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); //粗体
        sStr.setSpan(new RelativeSizeSpan(0.8f), 0,content_1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        textView.append(sStr);
    }

    public static void setTextStartAndEnd(TextView textView, String content_1, String content_2,int color1,int color2){
        textView.setText("");
        SpannableString sStr = new SpannableString(content_1 + content_2);
        sStr.setSpan(new ForegroundColorSpan(LPWHApplication.getContext().getResources().getColor(color1,null))
                , 0, content_1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);//设置字体颜色
        sStr.setSpan(new ForegroundColorSpan(LPWHApplication.getContext().getResources().getColor(color2,null))
                , content_1.length(), content_1.length()+content_2.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);//设置字体颜色
        sStr.setSpan(new StyleSpan(android.graphics.Typeface.BOLD),  0, content_1.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); //粗体
        textView.append(sStr);
    }

    public static void setTextCarNumber(TextView textView, String content_1, String content_2){
        textView.setText("");//"¥"
        SpannableString sStr = new SpannableString(content_1 + content_2);
        sStr.setSpan(new ForegroundColorSpan(LPWHApplication.getContext().getResources().getColor(R.color.color_5ed,null))
                , content_1.length(), content_1.length()+content_2.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);//设置字体颜色
        textView.append(sStr);

    }

}
